﻿Public Class FrmPruebasIndividuales
    Dim tim As Integer
    Dim caminoprof, caminoAmp, caminoAe As Queue
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If CBprof.Checked Or CBamp.Checked Or CBaestrella.Checked Then
            Dim tiempo1prof, tiempo1amp, tiempo1ae, tiempo2prof, tiempo2amp, tiempo2ae As DateTime
            Dim totalTimeprof, totalTimeamp, totalTimeae As TimeSpan
            Dim memprof1, memprof2, memamp1, memamp2, memae1, memae2, totalmemprof, totalmemamp, totalmemae As Double
            Timer3.Interval = 1000
            tim = 0
            Timer3.Enabled = True
            LBTimer.Visible = True
            Label5.Visible = True
            If CBprof.Checked Then
                tiempo1prof = DateTime.Now
                memprof1 = FrmTablero.consumoMem()
                caminoprof = FrmTablero.tableroAjedrez.primeroprof(FrmTablero.tableroAjedrez, FrmTablero.posiscionCaballoNegro)
                memprof2 = FrmTablero.consumoMem()
                tiempo2prof = DateTime.Now
                totalTimeprof = New TimeSpan(tiempo2prof.Ticks - tiempo1prof.Ticks)
                totalmemprof = (memprof2 - memprof1)

            End If
            If CBamp.Checked And Not FrmTablero.terminar Then
                tiempo1amp = DateTime.Now
                memamp1 = FrmTablero.consumoMem()
                caminoAmp = FrmTablero.tableroAjedrez.primeroamplitud(FrmTablero.tableroAjedrez, FrmTablero.posiscionCaballoNegro)
                memamp2 = FrmTablero.consumoMem()
                tiempo2amp = DateTime.Now
                totalTimeamp = New TimeSpan(tiempo2amp.Ticks - tiempo1amp.Ticks)
                totalmemamp = (memamp2 - memamp1)
            End If
            If CBaestrella.Checked And Not FrmTablero.terminar Then
                tiempo1ae = DateTime.Now
                memae1 = FrmTablero.consumoMem()
                caminoAe = FrmTablero.tableroAjedrez.Aestrella(FrmTablero.tableroAjedrez, FrmTablero.posiscionCaballoNegro)
                memae2 = FrmTablero.consumoMem()
                tiempo2ae = DateTime.Now
                totalTimeae = New TimeSpan(tiempo2ae.Ticks - tiempo1ae.Ticks)
                totalmemae = (memae2 - memae1)
            End If
            If Not FrmTablero.terminar Then
                If CBprof.Checked Then
                    LBLongCamProf.Text = CStr(caminoprof.Count - 1)
                    LBTimeEjProf.Text = CStr(totalTimeprof.Hours) + " : " + CStr(totalTimeprof.Minutes) + " : " + CStr(totalTimeprof.Seconds) + " : " + CStr(totalTimeprof.Milliseconds)
                    LBUsoMemProf.Text = CStr(totalmemprof) + "KB"
                    LBLongCamProf.Visible = True
                    LBTimeEjProf.Visible = True
                    LBUsoMemProf.Visible = True
                End If
                If CBamp.Checked Then
                    LBLongCamAmp.Text = CStr(caminoAmp.Count - 1)
                    LBTiemEjAmp.Text = CStr(totalTimeamp.Hours) + " : " + CStr(totalTimeamp.Minutes) + " : " + CStr(totalTimeamp.Seconds) + " : " + CStr(totalTimeamp.Milliseconds)
                    LBUsoMemAmp.Text = CStr(totalmemamp) + "KB"
                    LBLongCamAmp.Visible = True
                    LBTiemEjAmp.Visible = True
                    LBUsoMemAmp.Visible = True
                End If
                If CBaestrella.Checked Then
                    LBLongCamAe.Text = CStr(caminoAe.Count - 1)
                    LBTimeEjAe.Text = CStr(totalTimeae.Hours) + " : " + CStr(totalTimeae.Minutes) + " : " + CStr(totalTimeae.Seconds) + " : " + CStr(totalTimeae.Milliseconds)
                    LBUsoMemAe.Text = CStr(totalmemae) + "KB"
                    LBLongCamAe.Visible = True
                    LBTimeEjAe.Visible = True
                    LBUsoMemAe.Visible = True
                End If
            End If
            If Not FrmTablero.terminar Then
                LBCantCBs.Text = FrmTablero.tableroAjedrez.CantidadCaballoBlanco
                LBPosCN.Text = FrmTablero.posiscionCaballoNegro
                GroupBox2.Visible = True
            End If
            Timer3.Enabled = False
            LBTimer.Visible = False
            Label5.Visible = False
            LBTimer.Text = "0"
            If FrmTablero.terminar Then
                MsgBox("El proceso ha sido detenido")
                FrmTablero.terminar = False
            End If
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        GroupBox2.Visible = False
        LBLongCamProf.Visible = False
        LBTimeEjProf.Visible = False
        LBLongCamAmp.Visible = False
        LBTiemEjAmp.Visible = False
        LBLongCamAe.Visible = False
        LBTimeEjAe.Visible = False
        LBUsoMemAe.Visible = False
        LBUsoMemAmp.Visible = False
        LBUsoMemProf.Visible = False
        FrmTablero.nuevoTablero()
        Me.Close()
    End Sub

    Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
        tim = tim + 1
        LBTimer.Text = CStr(tim)
        Me.Refresh()
    End Sub

    Private Sub BTParar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTParar.Click
        FrmTablero.parar = True
    End Sub
End Class